//
//  DataBaseTests.m
//  JKOCRealmTests
//
//  Created by 王冲 on 2019/2/27.
//  Copyright © 2019年 JK科技有限公司. All rights reserved.
//

#import <XCTest/XCTest.h>
#import "DataBaseModel.h"
#import <Realm/Realm.h>
#import "RLMRealmDataBaseTools.h"
@interface DataBaseTests : XCTestCase

@end

@implementation DataBaseTests

- (void)setUp {
    
}

- (void)tearDown {
   
}

#pragma mark 数据库的配置
- (void)testExample1 {
    //  数据库的操作
    [RLMRealmDataBaseTools setRealmDefaultRealmForUserDatabaseName:@"王二"];
    
    DataBaseModel *model = [DataBaseModel new];
    model.number = 1;
    
    RLMRealm *realm = [RLMRealm defaultRealm];
    
    [realm transactionWithBlock:^{
       
        [realm addObject:model];
    }];
    
}

#pragma mark 
- (void)testExample2{
    
    [RLMRealmDataBaseTools setRealmDefaultRealmReadOnly];
 
    // 通过配置打开 Realm 数据库
    RLMRealm *realm = [RLMRealm defaultRealm];
    // 从打包的 Realm 数据库中读取某些数据
    
    DataBaseModel *model = [DataBaseModel new];
    model.number = 2;
    [realm transactionWithBlock:^{
        [realm addObject:model];
    }];
    
}

#pragma mark 删除指定用户的数据库
- (void)testExample3{
    
   
    [RLMRealmDataBaseTools deleteRealmDatabaseName:@"王二"];
}
    

@end
